package com.saint.empty;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;

import java.io.IOException;
import java.io.InputStream;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String tips = readAssetsTextReturnStr();
        if (TextUtils.isEmpty(tips)) tips = getString(R.string.tips);
        Toast.makeText(this, tips, Toast.LENGTH_SHORT).show();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                MainActivity.this.finish();
            }
        });
        thread.start();
    }

    public String readAssetsTextReturnStr() {
        try {
            InputStream is = getAssets().open("tips");
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            String text = new String(buffer, "utf-8");
            return text;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "读取错误，请检查文件名";
    }
}
